package com.Service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.Mapper.AccountMapper;
import com.Pojo.Account;
import com.Service.Account_Service;
import com.util.Encrypt;

@Service
public class Account_Service_Im implements Account_Service {
	@Autowired
	private AccountMapper accountMapper;
	public int insertAccount(String userName, String password) {
		Account acc = new Account();
		acc.setUsername(userName);
		acc.setPassword(password);
		acc.setUpdatetime(new Date());
		acc.setCreatetime(new Date());
		int insert = accountMapper.insert(acc);
		return insert;
	}

	public Account selectByNameKey(String name) {
		Account account = accountMapper.selectByNameKey(name);
		return account;
	}

	public int updateAccount(Account account) {
		
		return accountMapper.updateByPrimaryKeySelective(account);
	}

	public int updateAccountPwd(int id, String password) {
		Account account = new Account();
		account.setId(id);
		account.setPassword(Encrypt.md5(password));
		account.setUpdatetime(new Date());
		return accountMapper.updateByPrimaryKeySelective(account);
	}

	public Account selectByPrimaryKey(Integer id) {
		
		return accountMapper.selectByPrimaryKey(id);
	}



}
